﻿/* ==============================================================================
 * 功能描述：SkillPanelTips  
 * 
 * 创 建 者：郑镇泉
 * 
 * 创建日期：2016/4/14 17:21:05
 * ==============================================================================*/
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using ZZQFrameWork;

/// <summary>
/// 技能面板tips
/// </summary>
public class SkillPanelTips : MonoBehaviour
{
    /// <summary>
    /// 技能图标
    /// </summary>
    private Image iconImage;

    /// <summary>
    /// 技能名称
    /// </summary>
    private Text nameText;

    /// <summary>
    /// 技能描述
    /// </summary>
    private Text desText;

    /// <summary>
    /// 技能等级
    /// </summary>
    private Text lvText;

    //private SkillVO data;

    //public SkillVO Data
    //{
    //    get { return data; }
    //    set
    //    {
    //        data = value;
    //        UpdateShow();
    //    }
    //}

    void Awake()
    {
        iconImage = transform.GetComponentByPath<Image>("BG/Icon");
        nameText = transform.GetComponentByPath<Text>("BG/Name");
        desText = transform.GetComponentByPath<Text>("BG/Des");
        lvText = transform.GetComponentByPath<Text>("BG/Lv");
        OnSkillPanelTipsShow(null);
    }

    void OnEnable()
    {
        EventDispatcher.AddListener<SkillVO>(Events.CharacterEvent.OnSkillPanelTipsShow,OnSkillPanelTipsShow);
    }

    void OnDisable()
    {
        EventDispatcher.RemoveListener<SkillVO>(Events.CharacterEvent.OnSkillPanelTipsShow, OnSkillPanelTipsShow);
    }

    /// <summary>
    /// 技能信息显示
    /// </summary>
    /// <param name="data"></param>
    private void OnSkillPanelTipsShow(SkillVO data)
    {
        if (data == null)
        {
            iconImage.sprite = null;
            nameText.text = null;
            desText.text = null;
            lvText.text = null;
            return;
        }
        iconImage.sprite = UIAtlasManager.Instance.GetUIAtlasByName("Skill_Atlas").GetSprite(data.icon);
        nameText.text = data.name;
        desText.text = data.des;
        lvText.text = "LV：" + data.lv;
    }
}